package com.codeberry.yws2.examples;

import com.codeberry.yws2.*;

import java.io.*;

public class ConstantPageServer extends AbstractYoctoWebServer {
  public void process(Request request, Response response) throws IOException {
    String content = "<html><body>" +
                     "The request path: " + request.getPath() + "<br>" +
                     "Args: " + request.getArgs() + "<br>" +
                     "Method: " + request.getMethod() + "<br>" +
                     "<form action='test?arg1=v1' method='post'><input type='hidden' name='hidden1' value='value1'><input type='submit'></form>"+
                     "</body></html>";
    byte[] data = content.getBytes();
    OutputStream out = response.prepareOutputStream(ErrorCode.OK,
                                                    "Content-length: " + data.length,
                                                    "Content-type: text/html");
    out.write(data);
  }

  public static void main(String[] args) throws IOException {
    ConstantPageServer server = new ConstantPageServer();
    server.start();
  }
}
